package com.stylefeng.guns.modular.wz.warpper;

import com.stylefeng.guns.common.constant.Consts;
import com.stylefeng.guns.common.constant.factory.ConstantFactory;
import com.stylefeng.guns.core.base.warpper.BaseControllerWarpper;
import org.apache.commons.lang3.StringUtils;

import java.util.List;
import java.util.Map;

/**
 * @program: guns
 * @description: 用户包装类
 * @author: Chenchao
 * @create: 2018-04-25 13:37
 **/
public class WzUserWarpper extends BaseControllerWarpper {
    public WzUserWarpper(List<Map<String, Object>> list) {
        super(list);
    }

    @Override
    protected void warpTheMap(Map<String, Object> map) {
        map.put("gender", ConstantFactory.me().getDictsByName("性别", Integer.parseInt(map.get("gender").toString())));
        map.put("role", ConstantFactory.me().getDictsByName("用户角色", Integer.parseInt(map.get("role").toString())));
        map.put("status", ConstantFactory.me().getDictsByName("用户状态", Integer.parseInt(map.get("status").toString())));
        if (StringUtils.isNotBlank(map.get("avatarUrl").toString())) {
            String avatarUrl = map.get("avatarUrl").toString().substring(0, 4);
            if (!avatarUrl.equals("http")) {
                avatarUrl = Consts.DOMAIN + map.get("avatarUrl").toString();
                map.put("avatarUrl", avatarUrl);
            }
        }
    }
}
